package view;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;

/**
 * description:
 *
 * @author wht
 * @createDate 2022/12/28 16:47
 */
public class MemoryView {

    private MainView mainView;

    AnchorPane memoryBlockview;
    static GridPane memoryView;



    public MemoryView(MainView mainView, AnchorPane memoryBlockview, GridPane memoryView) {
        this.mainView = mainView;
        this.memoryBlockview = memoryBlockview;
        this.memoryView = memoryView;
    }


    public void initMemoryChart() {
        GridPane lookup = (GridPane) memoryBlockview.lookup("#memoryGridView2");
        for (int i = 0; i < 2; i++) {
            if (i == 0) lookup.getChildren().get(i).setStyle("-fx-background-color: DeepSkyBlue ;-fx-border-color: #EEEEBB");
            if (i == 1) lookup.getChildren().get(i).setStyle("-fx-background-color: Magenta ;-fx-border-color: #EEEEBB");
        }
        for (int i = 0; i < 64; i++) {
            Pane pane = (Pane) memoryView.getChildren().get(i);
            pane.setStyle("-fx-background-color: Magenta ;-fx-border-color: #EEEEBB");
        }
    }
    /**
     * 设置内存表格展示
     */
    public void updateMemoryChart() { //TODO 展示内存块使用情况
        for (int i = 0; i < 64; i++) {
            Pane pane = (Pane) memoryView.getChildren().get(i);

            pane.setStyle("-fx-background-color: Magenta ;-fx-border-color: #EEEEBB");
        }
    }

    public static void updateMemoryChartToUnUse(int blockNum) {
            Pane pane = (Pane) memoryView.getChildren().get(blockNum);

            pane.setStyle("-fx-background-color: Magenta ;-fx-border-color: #EEEEBB");

    }

    public static void updateMemoryChartToUse(int blockNum) {
            Pane pane = (Pane) memoryView.getChildren().get(blockNum);

            pane.setStyle("-fx-background-color: #002aff ;-fx-border-color: #EEEEBB");

    }
}
